package flc.ast.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.util.Random;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.bean.StkResBean;

public class CollectAdapter extends StkProviderMultiAdapter<StkResBean> {


    public CollectAdapter() {
        addItemProvider(new CollectItemProvider());
    }


    private class CollectItemProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_update;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
            baseViewHolder.setText(R.id.tvUpdateItemTitle, bean.getName());
            Glide.with(baseViewHolder.itemView).load(bean.getThumbUrl()).into((ImageView) baseViewHolder.getView(R.id.ivUpdateItemImg));
            Random random = new Random();
            int num = random.nextInt(5000) + 1000;
            baseViewHolder.setText(R.id.tvUpdateItemCollect, num + "");
            baseViewHolder.setImageResource(R.id.ivUpdateItemCollect, R.drawable.sc2);
            int num1 = random.nextInt(9);
            int num2 = random.nextInt(9);
            baseViewHolder.setText(R.id.tvUpdateItemHot, getContext().getString(R.string.hot_text, num1, num2));
        }
    }
}
